// townscript for town 41: final fight

begintownscript;

variables;

int choice,i,j,x;

body;

beginstate INIT_STATE;

	set_name(6,"Bohevan");
	set_level(8,28);
	set_name(8,"Captain Clunk");
	set_level(12,25);
	set_level(13,25);
	set_level(14,25);

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	move_to_new_town(4,5,5);
break;

beginstate 11;
if (get_flag(41,1) == 1)
		end();
	message_dialog("Full of awe, you stand in front of an enormous underground hall. It must be ancient. Big rock pillars support the ceiling. You can see two altars and a few people standing next to them.","You must try not to catch their attention, but to try to very silently walk to them, as close as possible, and then to attack.");
	set_flag(41,1,1);
break;

beginstate 12;
if (get_flag(41,2) == 0) {
		set_flag(41,2,1);
		put_boom_on_char(0,2,0);
		put_boom_on_char(1,2,0);
		put_boom_on_char(2,2,0);
		put_boom_on_char(3,2,0);
		put_boom_on_char(4,2,0);
		put_boom_on_char(5,2,0);
		run_animation_sound(10);
		pause(4);
		
		force_view_center(24,18);
		pause(6);
		
		relocate_character(0,24,18);
		relocate_character(1,24,19);
		relocate_character(2,24,20);
		relocate_character(3,24,21);
		relocate_character(4,24,22);
		relocate_character(5,24,23);
		pause(4);
		
		put_boom_on_char(0,2,0);
		put_boom_on_char(1,2,0);
		put_boom_on_char(2,2,0);
		put_boom_on_char(3,2,0);
		put_boom_on_char(4,2,0);
		put_boom_on_char(5,2,0);
		run_animation_sound(10);
		
		pause(10);
		
		text_bubble_on_char(7,"Welcome!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"You almost killed me");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"in the throne room.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"But this will change now.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"Now you,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"adventurers,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"will be killed.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"It will be painful");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"and long.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"I wish you no luck.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"Break a leg...");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"...and all your other bones.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"The time has come");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"if you lose this fight");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"nothing will stop me");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"from ruining Empire armies,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"forts,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"and their leaders.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"The battle");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"has begun.");
		force_instant_terrain_redraw();
		pause(15);
		
		message_dialog("The battle has begun, as Thralni said, but you are no step closer to the reason of his acting. Maybe, if you survive this final fight, you'll come to know about the how and why later.","If you survive...");
		
		move_to_new_town(41,24,22);
		}

break;

beginstate 13;
if (get_flag(41,3) == 1)
		end();

reset_dialog();
add_dialog_str(0,"You search through stone box. You don't find much. A few coins and a sort of journal. Would you like to read it?",0);
add_dialog_choice(0,"Read it");
add_dialog_choice(1,"Leave it");
choice = run_dialog(1);

	if (choice == 1) {
			reset_dialog();
			add_dialog_str(0,"You open it. It is no book of magic, nor a book of great wisdom. It is something much more priceless. It is Thralni's diary, of why he waited and prepared his revenge in this cave.",0);
			add_dialog_str(1,"It appears Thralni didn't have this underground castle until recently. The creation halls were built only a year ago. Thralni sat in this cave, in the chamber you had to destroy, trying to think of a suitable revenge.",0);
			add_dialog_str(2,"It is all very interesting. The whole journal starts with a small introduction:",0);
			add_dialog_choice(0,"Read on");
			choice = run_dialog(1);
			
			reset_dialog();
			add_dialog_str(0,"_Journal, written by Thralni, Emperor of Riverrod, Leafloss, year 840.",0);
			add_dialog_str(1,"_The Empire, ruled by the foolish Hawthorn, is a pest, and I can miss it as rotten teeth. He barged into the Thraldom, forcing me to flee. I have been to many places before I found this quite secluded cave._",0);
			add_dialog_str(2,"_There seems to be enough food - a small pond with strange cave fish, though edible. There are mushrooms, too. The only thing that worries me are these altars. They radiate a strange power, which I have never felt._",0);
			add_dialog_str(3,"_There is something with this cave, although I don't know what it is. This, however, could be the key to my revenge._",0);
			add_dialog_choice(0,"Read on");
			choice = run_dialog(1);
			
			reset_dialog();
			add_dialog_str(0,"You read on, until you come to this interesting bit written year later:",0);
			add_dialog_str(1,"_Leafloss, year 841._",0);
			add_dialog_str(2,"_These altars are exactly what I look for! They seem to drain the power of the gods themselves, when enchanting a certain formula. The formula was written on the cave wall, but I removed it and wrote it on a piece of paper._",0);
			add_dialog_str(3,"_They also seem to encourage and strengthen the one enchanting. I tried this on me, making myself extremely powerful. If I could use this power, I could set up an army in no time._",0);
			add_dialog_choice(0,"Read on");
			choice = run_dialog(1);
		
			reset_dialog();
			add_dialog_str(0,"The journal explains most of the things you had hoped to hear from Thralni himself, but you still don't know how he got this _power_ to the creation halls. This must have cost energy, energy from where?",0);
			add_dialog_str(1,"You read on. After a few pages, also this last question is answered:",0);
			add_dialog_str(2,"_I found the perfect location for my plan. The only problem is transporting the powers of the altar to this place. I have been thinking of ways to move the altars, but it didn't seem to work._",0);
			add_dialog_str(3,"_I found the solution! The only thing I have to do, is to enchant the machines that supply the power for my plan. All I need for that, is to find out how the altar works..._",0);
			add_dialog_choice(0,"Read on");
			choice = run_dialog(1);
			
			reset_dialog();
			add_dialog_str(0,"The next page explains how the plan was to be executed.",0);
			add_dialog_str(1,"_The power supply of the Creation halls will consist of a series of projector beams and small power sources, following each other. One shoots a beam, which is absorbed by the next power source in the series._",0);
			add_dialog_str(2,"_In the end, a very powerful beams is projected to the last, big power source. This reactor absorbs this powerful beam and sends it up. However, before this happens, it goes through a series of machinery._",0);
			add_dialog_str(3,"_The machinery is located on both sides of the power supply level. The power is divided over big crystals (each machine has a crystal) in which the power of the altars is given to the beams._",0);
			add_dialog_choice(0,"Read on");
			choice = run_dialog(1);
			
			reset_dialog();
			add_dialog_str(0,"You finally come to the last pages of Thralni's journal.",0);
			add_dialog_str(1,"_Getting the power out of the altars was a very complicated process, of which only I know how it should be done. I'm not going to write it down, too. If this journal was to fall in wrong hands, God knows what will happen._",0);
			add_dialog_str(2,"_My plan goes well. Everything is as it should be. My creations, the Senarti, already destroyed one big town, called Summertown. I look forward to the crumbling of the Empire headquarters._",0);
			add_dialog_str(3,"_Then there is my personal army. Apart from my creations, I managed to find some corrupt Empire spies, who joined my side. However, I did have to sack a few people, such as Benthol.",0);
			add_dialog_choice(0,"Close the journal");
			choice = run_dialog(1);

			message_dialog("Benthol? So he worked for Thralni, and that's how he knew about the castle gates, and how to open them. He chose to help you, instead of serving the man he detested.","You pocket the journal. This may be very good evidence, as to how Thralni actually did all this. However, as you stand up, you feel your pocket getting heavy. You open it, and the journal is gone. A spell protecting it made it fall apart in sand.");
					
			if (get_flag(16,0) == 0) {
					message_dialog("The journal of Thralni got hold of you, and it won't let go. Thralni said in that diary that he awaited the destruction of the Riverrod Empire headquarters.","For some reason you have the very strong feeling that Commander Johnson was one of the spies of Thralni. If you hadn't let him be arrested, the Empire headquarters would be a ruin by now.");
					}
			
			message_dialog("Now that you know of Benthol, it might be a very good decision to confront him with this, so he can give his version of what happened.","");
			set_flag(41,3,1);
			}
break;

beginstate 14;
if (get_flag(41,4) == 1)
		end();
	message_dialog("You enter this small secluded chamber. You suspect Thralni might have lived here. You see big cracks in the wall to your right, and that small box to the left of you might have some nice trinkets belonging to Thralni.","");
	set_flag(41,4,1);
break;

beginstate 15;
if (get_flag(41,3) == 0) {
		message_dialog("It would be very unwise to leave this place without trying to find at least some sort of clue as to why Thralni took all this trouble to ruin his own Empire.","");
		block_entry(1);
		}
break;